#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/7/11 11:00
# @Author  : CoderCharm
# @File    : role.py
# @Software: PyCharm
# @Desc    :
"""
角色表crud操作
"""

from typing import List, Optional
from sqlalchemy.orm import Session
from sqlalchemy import func, or_

from api.common.curd_base import CRUDBase
from api.models.auth import Workflow

# from ..schemas import role_schema


class CRUDWorkflow(CRUDBase[Workflow,None,None]):

    # def create(self, db: Session, *, obj_in: role_schema.RoleCreate) -> Resource:
    #     db_obj = Role(
    #         name=obj_in.name,
    #         pid=obj_in.pid
    #     )
    #     db.add(db_obj)
    #     db.commit()
    #     db.refresh(db_obj)
    #     return db_obj

    #分页查询所有{"total":100,'list':reslit}
    @staticmethod
    def wf_setpromition(db: Session,*,wid:int,params:str) -> dict:
        print("****")
        print(wid)
        print(params)
        res = db.query(Workflow).filter(Workflow.id ==wid).update({Workflow.parmars:params})
        db.commit()
        if res:
            return True
        return False
   
    
curd_workflow = CRUDWorkflow(Workflow)
